<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>卫生机构</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">
        .laytable-cell-radio.layui-table-cell {
            padding: 0 5px 0 15px;
        }
        
        .laytable-cell-radio span {
            display: none;
        }
        
        .laytable-cell-radio .layui-form-radio {
            padding-right: 0;
            margin: 0;
        }
        
        .layui-form-select dl dd.layui-this {
            background-color: #1e9FFF;
        }
    </style>
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:130px">搜索卫生机构：</label>
            <div class="layui-inline">
                <input class="layui-input" name="id" id="demoReload" autocomplete="off" placeholder="请输入卫生机构名称">
            </div>
            区域：
            <div class="layui-inline">
                <select name="area" id="area" class="layui-input" lay-search>
                        <option value=""></option>
                </select>
            </div>
            <button class="layui-btn layui-btn-normal" data-type="reload" id="serch"> <i class="layui-icon">&#xe615;</i>查询</button>

        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    </div>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index'], function() {


            $.ajax({
                url: '../../../Cust/region',
                dataType: 'json',
                type: 'post',
                success: function(res) {
                    $.each(res.data, function(index) {
                        var n = res.data[index].n;
                        var value = res.data[index].value;
                        $("#area").append("<option value='" + value + "'>" + n + "</option>")

                    });
                    layui.form.render();

                }
            })
            layui.use('table', function() {
                var table = layui.table;
                var $ = layui.$;
                var tableIns = table.render({
                    elem: '#demo',
                    height: 'full-90',
                    url: '../../../Customer/customer',

                    page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） 						
                        limit: 50,
                        limits: [20, 50, 100, 150, 200],
                        theme: "#1E9FFF"
                    },
                    cols: [
                        [
                            //表头

                            {
                                field: 'name',
                                title: '名称',
                                width: '30%',
                                event: 'info',
                                templet: function(d) {
                                    if (d.booked == 1) {
                                        return '<span style="color:red">★</span>' + d.name
                                    } else {
                                        return d.name;
                                    }
                                }

                            }, {
                                field: 'address',
                                title: '地址',
                                width: '30%'
                            }, {
                                field: 'linkman',
                                title: '联系人',
                                width: '18%'
                            }, {
                                field: 'linktel',
                                title: '联系方式',
                                width: '18%'
                            }
                        ]
                    ],
                    skin: 'row' //表格风格
                        ,
                    even: true
                });
                table.on('tool(test)', function(obj) {
                    var d = obj.data;
                    if (obj.event === 'info' && d.booked == 1) {
                        layer.open({
                            type: 2,
                            area: ['100%', '100%'],
                            offset: 'auto',
                            title: [d.name + '详细信息', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                            content: 'hospitalinfo.html',
                            success: function(layero, index) {
                                var body = layer.getChildFrame('body', index);
                                body.find('#no').val(d.id);

                            }
                        })
                    }
                });

                $("#serch").on('click', function() {
                    tableIns.reload({
                        url: '../../../Customer/customer',
                        where: {
                            region: $("#area option:selected").val(),
                            custname: $("#demoReload").val()
                        } //设定异步数据接口的额外参数
                        ,
                        page: {
                            curr: 1, //重新从第 1 页开始
                            theme: "#1E9FFF"
                        }
                    });
                    $("table tr").css({
                        "background": "#1E9FFF",
                        "color": "white"
                    });
                });


                $("table tr").css({
                    "background": "#1E9FFF",
                    "color": "white"
                });
            });
        });
    </script>
</body>

</html>